package com.thoughtmechanix.licenses;

import com.thoughtmechanix.licenses.model.Organization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * 功能描述
 *
 * @author zgl
 * @version 1.0
 * @date 2019-07-27 15:39
 */
@Component
public class OrganizationDiscoveryClient {

    @Autowired
    RestTemplate restTemplate;


    public Organization getOrganization(String organizationId) {
        ResponseEntity<Organization> restExchange =
                restTemplate.exchange("http://organizationservice/v1/organizations/"+organizationId, HttpMethod.GET,
                        null, Organization.class, organizationId);
        return restExchange.getBody();
    }
}
